<?php
	//if ( ! defined('BASEPATH')) exit('No direct script access allowed');

/**
* @property DB_active_record $db
* @property Service $service
* @property Provider $provider
* */
class Main extends CI_Controller {
	var $xAddr = 0;
	var $yAddr = 0;

//	$data['include_view'] = "bagian.php" ;
	
	public function __construct()
	{
		parent::__construct();
		//$this->load->model("services");
//		$this->load->model("base_flexmodel");
		//$this->load->model("satu");
		//$this->load->model("provider");
		
//		$this->load->helper('captcha');
//		$this->load->library('parser');
		
//		$data['include_view'] = "bagian.php" ;
		
//		$this->load->library("searchaddress");
//		$this->load->library("input");
	}

	function index()
	{

//		$this->load->model("service");
//		$data['serviceList'] = $this->service->getAll() ;
//		$this->load->view('SearchByService', $data);
		//http://www.aic.sg/silverpages/eldercare/searchByServices.aspx#

//		$this->load->library('parser');
//
//		$data = array(
//					'blog_title' => 'My Blog Title'
//					, 'blog_heading' => 'My Blog Heading'
//					, 'body' => '< ? php include "bagian.php"  ? >'
//					);
//
//		$this->parser->parse('blog_template', $data);
////
////		//$this->load->view("bagian");
//		//$wew  = $this->load->view("bagian");
		
//		$data['bagiannya'] = "bagian.php" ;
//		$data['kedua'] = "keduanya" ;
//		$this->load->view("sebagian" , $data);
		
//		//$this->load->helper('url');
//		$this->load->helper('html');
//		
////		$data['include_view'] = "bagian.php" ;
//		$this->load->view("_Shared/_Layout" , $data);

		

		
//		$this->load->model("service");
//		$data['serviceList'] = $this->service->getAll() ;
//		
//		$this->load->helper('html');
//		$data['include_view'] = "Search/byService.php" ;
//		$this->load->view("_Shared/_Layout" , $data);

		
//		$this->load->model("base_flexmodel");
//		$this->load->model("provider");
//		ECHO "<PRE>";
//		ECHO var_dump($this->provider->insert ('1', 'Y', '3', 'a', '3', '3', 'B', 'U', '123', '3', '4', '5', '5') );
//		ECHO "</PRE>";
//			ECHO "<PRE>";
//			ECHO var_dump($this->provider->getProviderList() );
//			ECHO "</PRE>";
		
		$this->load->model("base_flexmodel");
		$this->load->model("service");
//		
//		
		ECHO "<PRE>";
		ECHO var_dump($this->service->getAll() );
		ECHO "</PRE>";

		$this->load->library('table');
		echo $this->table->generate( $this->service->getAll() ); 
		
		
	}
		
	
	
	function index33() {
		$this->load->library('table');
		
//
//		$data = array(
//					 array('Name', 'Color', 'Size'),
//					 array('Fred', 'Blue', 'Small'),
//					 array('Mary', 'Red', 'Large'),
//					 array('John', 'Green', 'Medium')
//					 );
//
//		echo $this->table->generate($data); 
		
//		echo $this->table->generate( $this->provider->getAll() ); 
//			ECHO "<PRE>";
//			ECHO var_dump($this->provider->getAll());
//			ECHO "</PRE>";

//		$tmpl = array (
//			'table_open'          => '<table border="1" cellpadding="4" cellspacing="0">',
//
//			'heading_row_start'   => '<tr>',
//			'heading_row_end'     => '</tr>',
//			'heading_cell_start'  => '<th>',
//			'heading_cell_end'    => '</th>',
//
//			'row_start'           => '<tr>',
//			'row_end'             => '</tr>',
//			'cell_start'          => '<td>',
//			'cell_end'            => '</td>',
//
//			'row_alt_start'       => '<tr>',
//			'row_alt_end'         => '</tr>',
//			'cell_alt_start'      => '<td>',
//			'cell_alt_end'        => '</td>',
//
//			'table_close'         => '</table>'
//		);
//		$this->table->set_template($tmpl); 
//		
//		//$this->table->set_heading(array('Name', 'Color', 'Size'));
//		
//		echo $this->table->generate( $this->provider->getAll() ); 
		
		

	}
	
	
	function indexXX() {
//		$data = array();
//		ECHO "<PRE>";
//		ECHO var_dump($this->services->get());
//		ECHO "</PRE>";
//		exit;
//		
		
//		ECHO "<PRE>";
//		ECHO var_dump($this->satu->getSatu());
//		ECHO "</PRE>";

//echo '<img src="http://example.com/captcha/12345.jpg" width="140" height="50" />';

//$vals = array(
//    'word' => 'Random word',
//    //'img_path' => './captcha/',
//	'img_path' => ROOTPATH . '/all_captcha/aic_new/',
//    //'img_url' => 'http://localhost/aic_new/captcha/',
//	'img_url' => 'http://localhost/all_captcha/aic_new/',
//    //'font_path' => './path/to/fonts/texb.ttf',
//    'img_width' => '150',
//    'img_height' => 30,
//    'expiration' => 7200
//    );
//
//$cap = create_captcha($vals);
//echo $cap['image'];
////
//////C:\xampp\htdocs\aic_new\views\capcai

//			echo "\$data = " . 123 . "</BR>";;
//			exit;
		
//		$this->load->library('parser');
//
//		$data = array(
//					'blog_title' => 'My Blog Title',
//					'blog_heading' => 'My Blog Heading'
//					);
//
//		$this->parser->parse('blog_template', $data);
			

//		$template['t_direction2']['template'] = 'templates/template_journey';
//		
//		$this->template->set_template("t_direction2");		
//		
//		$this->template->write_view('lhs','journey/direction_lhs',$data_lhs, FALSE);
//		$this->template->write_view('content', $this->mappage_portal->load_view("main_map/sg/main_map_view"), $data_map, TRUE);
//		//$this->template->write_view('content', $this->mappage_portal->load_view("journey/journey_map_view"), $data_map, TRUE);
//		//$this->template->write_view('cfooter', $this->mappage_portal->load_view("main_map/sg/main_map_cfooter_view"), '', TRUE);
//		$this->template->write_view('js_bottom_scripts', $this->mappage_portal->load_view("main_map/sg/js_main_map_view"), $data_js_footer, TRUE);
//		$this->template->write_view('footer', $this->mappage_portal->get_view("main_map/sg/main_map_bottom_view"), $data_bottom, FALSE);
//		$this->add_google_ads();
//
//		$output = $this->template->render('', TRUE);
//		
		
		
		
		
//		$data['baseUrl'] = $this->config->item('base_url');
//		$data['zones'] = $this->services->getDgpZones();
//		$data['services'] = $this->services->get();
//
//		if ($data['zones'] && $data['services'])
//			$this->load->view('default01', $data);
//		else 
//			show_404();
		
		
		
	}
	
//	function index2() {
//		$data = array();
//		$data['baseUrl'] = $this->config->item('base_url');
//		$data['zones'] = $this->services->getDgpZones();
//		$data['services'] = $this->services->get();
//
//		if ($data['zones'] && $data['services'])
//			$this->load->view('default02', $data);
//		else 
//			show_404();		
//	}
//	
//	function form() {
//		$data = array();
//		$data['baseUrl'] = $this->config->item('base_url');
//		$data['services'] = $this->services->get();
//		$data['providers'] = $this->services->getProvider('','',true);
//		$this->load->view('formzone', $data);
//	}
//	
//	function searchByService() {
//		$this->load->library("gis/gisutil");
//		$param = $this->uri->uri_to_assoc(3);
//		$pZone = isset($param['region']) ? $param['region'] : false;
//		$pServ = isset($param['service'])/* && strlen($param['service']) > 10*/ ? $param['service'] : false;
//		$pPage = isset($param['page']) && $param['page'] > 0 ? $param['page'] : 0;
//
//		//check number of parameter
//		if(func_num_args() > 6) show_404();
//		
//		//filter parameter
//		$pZone = $this->input->xss_clean($pZone);
//		$pServ = $this->input->xss_clean($pServ); 
//		$pPage = $this->input->xss_clean($pPage); 
//		
//		//chech parameter length
//		if( strlen($pZone) > 160
//			|| strlen($pPage) > 15
//		) show_404();
//		
//		//if ($pZone && $pZone > 0) {
//			$data = array();
//			$data['baseMap'] = $_SERVER['HTTP_HOST']."/xg/";
//			$data['baseUrl'] = $this->config->item('base_url');
//			//$data['cpage'] = $pPage;
//			//$total = $this->services->getByProvider(null, $pServ, $pZone, true);
//			//$data['page'] = $this->_getServicePage($param, $pPage, $total);
//			//$data['providers'] = $this->services->getByProvider(null, $pServ, $pZone, false, $pPage);
//			$data['allRegionMode'] = $pZone == -1 ? true : false;
//			$data['service'] = $pServ == -1 ? false : $pServ;
//			$data['zones'] = $this->services->getDgpZones($pZone, $pServ);
//			$data['desc'] = $this->_getDescription($pServ && $pServ != -1 ? 
//				$this->services->get($pServ) : false, 
//				$this->services->getByProvider(null, $pServ, $pZone), 
//				$pZone == -1 ? $pZone : $data['zones'], false, '', '', '', '');			
//			//$data['zonesProvider'] = $data['allRegionMode'] ? $zP : false;
//			$zone = $pZone == -1 && $data['zones'] ? $data['zones'][0]->zone_id 
//				: (strpos($pZone, ",") ? substr($pZone, 0, strpos($pZone, ",")) : $pZone);
//			$data['providers'] = $this->services->getByProvider(null, $pServ, $zone);
//			$this->load->view('maplist2', $data);
//		//}		
//	}
//	
//	function _getServicePage($param, $currentPage, $total) {
//		$this->load->library('pagination');
//		$config['base_url'] = $this->config->item('base_url')."default.php";
//		$config['base_url'] .= "/main/searchByService/";
//		$config['base_url'] .= isset($param['region']) ? "region/". $param['region']."/" : '';
//		$config['base_url'] .= isset($param['service']) ? "service/". $param['service']."/" : '';
//		$config['base_url'] .= "page/";
//		$config['total_rows'] = $total;
//		$config['cur_page'] = $currentPage;
//		$config['per_page'] = 10;
//		$this->pagination->initialize($config);
//		return $this->pagination->create_links();
//	}
//	
//	function map() {
//		$id = $this->input->get('id');
//		$postal = str_replace(' ','',$this->input->get('postalcode'));
//		$telp = $this->input->get('tel');
//		$company = $this->input->get('company');
//		$unit = $this->input->get('unitno');
//		$building = $this->input->get('buildingname1');
//		
//		//filter and clean parameter
//		if(	strlen($id) > 25
//			|| strlen($postal) > 6
//			|| strlen($telp) > 50
//			|| strlen($company) > 255
//			|| strlen($unit) > 25
//			|| strlen($building) > 100
//		) show_404();
//
//		$address = false;
//		if ($id > 0) {
//			$address = $this->services->getProvider($id);
//		} else {			
//			$address = $this->services->getProviderByPostal($postal);
//			if (!$address) {
//				$address = $this->searchaddress->postal(FALSE, $postal);
//			}
//		}
//		
//		if ($address) {
//			$data = array();
//			$_address = isset($_GET) ? array_merge(get_object_vars($address[0]), $_GET) : get_object_vars($address[0]);
//			$data['address'] = $this->_formatAddr($_address);
//			$data['title'] = $company != '' ? $company : (isset($address[0]->place_name) ? $address[0]->place_name : '');
//			$data['baseUrl'] = $_SERVER['HTTP_HOST'];
//			$data['bLevel'] = 5;
//			$pid = FALSE;
//			if ($address && isset($address[0]->pro_id)) {
//				$id = "";
//				foreach ($address as $r) {
//					$id .= $r->pro_id . ",";
//				}
//				$pid = substr($id, 0, strlen($id)-1);
//			}
//			$data['nl'] = $this->services->getNeighbourhoodLink($pid);
//			if ($data['nl']) {
//				$this->load->library('gis/Gisutil');
//				$xydata = '';
//				foreach ($data['nl'] as $r) {
//					$xydata .= $r->x_addr . "," . $r->y_addr . ",";
//				}
//				$xydata = $xydata.$address[0]->x_addr.",".$address[0]->y_addr;
//				$attr = $this->gisutil->get_center_level($xydata, 500, 450);
//				$data['bLevel'] = $attr->level;
//			}
//			$data['currentX'] = $address[0]->x_addr;
//			$data['currentY'] = $address[0]->y_addr;
//			$this->load->view('mapdefault.php', $data);
//		} else {
//			show_404();
//		}
//	}
//	
//	function mapZone() {
//		//filter parameter
//		$getProId = $this->input->get('pro_id');
//		$getTypeId = $this->input->get('type_id');
//		$postProId = $this->input->post('pro_id');
//		$postTypeId = $this->input->post('type_id');
//
//		$getPostal = $this->input->get('postal');
//		$getBuilding = $this->input->get('building');
//		$getStreetNo = $this->input->get('streetno');
//		$getStreetname = $this->input->get('streetname');
//		$postPostal = $this->input->post('postal');
//		$postBuilding = $this->input->post('building');
//		$postStreetNo = $this->input->post('streetno');
//		$postStreetname = $this->input->post('streetname');
//
//		//filter and clean parameter
//		if(	strlen($getBuilding) > 25
//			|| strlen($getStreetNo) > 25
//			|| strlen($getStreetname)> 50
//			|| strlen($postBuilding) > 25
//			|| strlen($postStreetNo) > 25
//			|| strlen($postStreetname) > 50
//		) show_404();
//		
//		$proArrayId = $postProId != FALSE ? $postProId : ($getProId != FALSE ? $getProId : FALSE);
//		$typeArrayId = $postTypeId != FALSE ? $postTypeId : ($getTypeId != FALSE ? $getTypeId : FALSE);
//		$postal = $postPostal != FALSE ? $postPostal : ($getPostal != FALSE ? $getPostal : FALSE);
//		$streetNo = $postStreetNo != FALSE ? $postStreetNo : ($getStreetNo != FALSE ? $getStreetNo : FALSE);
//		$streetname = $postStreetname != FALSE ? $postStreetname : ($getStreetname != FALSE ? $getStreetname : FALSE);
//		$building = $postBuilding != FALSE ? $postBuilding : ($getBuilding != FALSE ? $getBuilding : FALSE);
//		
//		if ($proArrayId || $typeArrayId) {
//			$data = array();
//			$typeId = is_array($typeArrayId) && count($typeArrayId) > 0 ? implode(",", $typeArrayId) : $typeArrayId;
//			$proId = is_array($proArrayId) && count($proArrayId) > 0 ? implode(",", $proArrayId) : $proArrayId;
//			$data['userAddress'] = $this->searchaddress->get(FALSE, $postal, $building, $streetNo, $streetname);
//			//$data['providers'] = $this->services->getByProvider($proId, $typeId);
//			$providers = $this->services->getByProvider($proId, $typeId);
//			if(false === $providers) show_404();
//			/*
//			if ($providers) {
//				$total = count($providers);
//				$totalpage = ceil($total/10);
//				$tmp = array();
//				for ($i = 0; $i < $totalpage; $i++) {
//					$start = $i * 10;
//					array_push($tmp, array_slice($providers, $start, 10));
//				}
//				$data['providers'] = $tmp;
//				echo "<pre>";
//				print_r($tmp);
//				echo "</pre>";
//    		}
//    		*/
//    		$data['providers'] = $providers;
//    		$data['typeId'] = isset($typeId) && $typeId != "" ? $typeId : false;
//			$data['serviceParam'] = isset($typeId) 
//				&& $typeId != "" && !strpos($typeId, ",") ? true : false;
//			$data['baseUrl'] = $this->config->item('base_url');
//			$data['baseMap'] = $_SERVER['HTTP_HOST'];
//			$data['desc'] = $this->_getDescription($typeId ? $this->services->get($typeId) : false, 
//				$providers, false, isset($data['userAddress']) ? $data['userAddress'] : false,
//				$postal, $building, $streetNo, $streetname);
//			$data['mapAttr'] = $this->services->getCenterLevel(
//				isset($data['userAddress']) ? $data['userAddress'] : false, $providers, 780, 500);
//			$this->load->view('mapzone2', $data);
//		} else {
//			show_404();
//		}
//	}
//
//	function _getDescription($service, $providers, $zones,
//		$userAddress, $postal, $building, $streetNo, $streetName) {
//		$cProvider = 0;
//		if (is_array($providers)) {
//
//			$no = 0;
//			foreach ($providers as $prov) {
//				if (!isset($prov->no)) {
//					foreach ($prov as $p) {
//						if ($no != $p->no) $cProvider++;
//						$no = $p->no;	
//					}
//				} else {
//					if ($no != $prov->no) $cProvider++;
//					$no = $prov->no;
//				}
//			}
//		}
//		$desc = "<p>You have searched for providers who provide ";
//		if ($service) {
//			$c = count($service);
//			if ($c > 1) {
//				$desc .= "services: <br />";		
//				for ($i = 0; $i < $c; $i++) {
//					$desc .= "<strong>".$service[$i]->name."</strong>";
//					if ($i != $c-1) $desc .= ", ";
//				}
//			} else if ($c == 1) {
//				$desc .= "service <strong>".$service[0]->name."</strong>";
//			}
//		} else {
//			$desc .= "<strong>All Services</strong>";
//		}
//		
//		if ($zones) {
//			if (is_array($zones)) {
//				$cz = count($zones);
//				$desc .= " and are in the ".($cz > 1 ? "regions " : "region ");
//				for ($i = 0; $i < $cz; $i++) {
//					$desc .= "<b>".ucwords(strtolower($zones[$i]->zone_name))."</b>";
//					if ($i != $cz-1) $desc .= ", ";
//				}
//			} else if ($zones == -1) {
//				$desc .= " and are in <b>All Regions</b> ";
//			}
//		}
//		
//		if ($userAddress) {
//			$desc .= ". <p>You have specified your location as ";
//			if ($postal != '') $desc .= "postal <strong>".$postal."</strong>";
//			else if ($building != '') $desc .= "building <strong>".$building."</strong>";
//			else if ($streetNo != '' && $streetName != '') $desc .= "street <strong>".$streetNo."</strong> <strong>".$streetName."</strong>";
//		}
//		$desc .= ". There are <strong>".($cProvider)." providers</strong> found.</p>";
//		/*
//		if ($zones) {
//			$desc .= " Please click here to <a href='".$this->config->item('base_url')."index.php?mode2'>search again</a>.";
//		}
//		*/
//		return $desc;
//	}
//
//	function _formatAddr($post) {
//		$isBuilding = (isset($post['building']) && $post['building']!='') 
//			|| (isset($post['place_name']) && $post['place_name']!='');
//        $str = isset($post['company']) ? $post['company']."<BR>" : '';
//
//		if (isset($post['streetname']) && $post['streetname']!="No Address")
//	        $str.= $post['block']." ".$post['streetname']."<BR>";
//        
//		if ((isset($post['unitno']) && $post['unitno'] !='') 
//			|| ($isBuilding)){
//			if (!isset($post['building']) && isset($post['unitno'])) $str .= $post['unitno']."<br>";
//			if (isset($post['place_name']) && $post['place_name'] != '') 
//				$str .= $post['place_name']."<br>";
//			//$str .= "<br>";
//		} else {
//			if (isset($post['unitno']) && trim($post['unitno'])!='') 
//				$str .= $post['unitno'];
//			if (isset($post['buildingname1']) && trim($post['buildingname1'])!='') 
//				$str .= " ".$post['buildingname1'];
//			//$str .= "<br>";
//		}		
//		if (isset($post['postal']) && $post['postal'] !="000000") 
//			$str.="SINGAPORE ".$post['postal'];
//		if (isset($post['tel']) && $post['tel'] != '')
//			$str.="<br>Tel :".$post['tel'];
//		$str = stripslashes($str);
//		return $str;
//	}
//	
//	function is_have_provider($zone,$type='json')
//	{
//		$zone = intval($zone);
//		
//		$this->load->database();
//		$this->db->where('zone',$zone);
//		$result = $this->db->get('ics_provider_data');
//		if($result->num_rows() > 0)
//			echo "true";
//		else
//			echo "false";
//	}
//
//	function searchType1()
//	{
//		if(! empty($_POST['search']))	
//		{		
//			$postal = ($this->input->post('postalcodex'))?$this->input->post('postalcodex'):"";
//			$block = ($this->input->post('blockx'))?$this->input->post('blockx'):"";
//			$street = ($this->input->post('streetx'))?$this->input->post('streetx'):"";
//			$building = ($this->input->post('buildingx'))?$this->input->post('buildingx'):"";
//			$range = ($this->input->post('range'))?$this->input->post('range'):"";
//			$type = ($this->input->post('type'))?$this->input->post('type'):"";
//			$search = ($this->input->post('search'))?$this->input->post('search'):"";
//			
//			//filter and clean data
//			if(	strlen($street) > 125
//				|| strlen($building) > 255
//				|| strlen($type) > 255
//				|| strlen($search) > 25
//			) show_404();
//			
//			foreach($type as $value)
//			{
//				$xml = simplexml_load_file ("http://www.street-directory.com/aic2/default.php/xmlout/searchByBoundary?postalcodex=$postal&blockx=$block&streetx=$street&buildingx=$building&range=$range&type=$value&search=$search");
//				//print_r($xml);
//				$num_rows = count($xml->provider);
//				for($i=0;$i<$num_rows;$i++)
//				{
//					if(! preg_match('/^\s*$/',strval($xml->servicetype)))
//					{
//
//						if(empty($service['type_id']))
//						{
//							$service['name'][] = strtoupper(strval($xml->servicename));
//							$service['type_id'][] = strtolower(strval($xml->servicetype));
//						}
//						else if(! in_array(strtolower(strval($xml->servicetype)),$service['type_id']))
//						{
//							$service['name'][] = strtoupper(strval($xml->servicename));
//							$service['type_id'][] = strtolower(strval($xml->servicetype));
//						}
//						if(! preg_match('/^\s*$/',strval($xml->servicetype))) $service_position = array_search(strtolower(strval($xml->servicetype)),$service['type_id']);
//						else $service_position = FALSE;
//					}
//					else
//					{
//						if(! preg_match('/^\s*$/',strval($xml->provider->$i->servicetype)))					
//						{
//							if(empty($service['type_id']))
//							{
//								$service['name'][] = strtoupper(strval($xml->provider->$i->servicename));
//								$service['type_id'][] = strtolower(strval($xml->provider->$i->servicetype));
//							}
//							else if(! in_array(strtolower(strval($xml->provider->$i->servicetype)),$service['type_id']))
//							{
//								$service['name'][] = strtoupper(strval($xml->provider->$i->servicename));
//								$service['type_id'][] = strtolower(strval($xml->provider->$i->servicetype));
//							}
//							 $service_position = array_search(strtolower(strval($xml->provider->$i->servicetype)),$service['type_id']);
//						}
//						else $service_position = FALSE;
//					}
//					if($service_position!==FALSE)
//					{
//						if(empty($state[$service_position]))
//						$state[$service_position][] = strtoupper(strval($xml->provider->$i->state));	
//						else if(! in_array(strtoupper(strval($xml->provider->$i->state)),$state[$service_position]))
//						$state[$service_position][] = strtoupper(strval($xml->provider->$i->state));	
//						$state_position = array_search(strtoupper(strval($xml->provider->$i->state)),$state[$service_position]);
//						
//						if(empty($provider[$service_position][$state_position]))
//						{
//							$provider[$service_position][$state_position]['id'][] = strtolower(strval($xml->provider->$i->id));
//							$provider[$service_position][$state_position]['name'][] = strtoupper(strval($xml->provider->$i->name));
//							$provider[$service_position][$state_position]['distance'][] = strval($xml->provider->$i->distance);
//						}
//						else if(! in_array(strtolower(strval($xml->provider->$i->id)),$provider[$service_position][$state_position]['id']))
//						{
//							$provider[$service_position][$state_position]['id'][] = strtolower(strval($xml->provider->$i->id));
//							$provider[$service_position][$state_position]['name'][] = strtoupper(strval($xml->provider->$i->name));
//							$provider[$service_position][$state_position]['distance'][] = strval($xml->provider->$i->distance);
//						}						
//					}
//				}
//			}
//			if(! empty($service))
//			{
//				$data['service'] = $service;
//				$data['state'] = $state;
//				$data['provider'] = $provider;
//			}
//			else
//			$data['provider'] = '';
//			$this->load->view('result1',$data);
//		}		
//		else
//		{
//			$this->db->select("name,type_id");
//			$query = $this->db->get("ics_services");
//			if($query->num_rows > 0)
//			{
//				$data['result'] = $query->result_array();
//			}
//			else $data['result'] = FALSE;
//			$this->load->view('type1',$data);
//		}
//	}	
//	
//	function test()
//	{
//		$this->load->database();
//		$this->load->model('related_parent');
//		$this->related_parent->set_fields(array('parent_id'=>'5'));
//		print_r($this->related_parent->get_result(1));
//	}
}









	
	/////////LUM IMPLEMENT, tar DL SC nya dl http://pr0digy.com/codeigniter/live-search-with-codeigniter-and-mootools/
//	public function index(){
//		$this->search('standard');
//	}
//
//	public function json(){
//		$this->search('json');
//	}
//
//	public function search($transport = null){
//		//load database
//		$this->load->database();
//		//load posts model
//		$this->load->model('Posts', 'posts');
//		//load JSON lib
//		$this->load->library('JSON', 'json');
//
//		//init posts array
//		$posts = array();
//
//		//validate and filter the input
//		if(isset($_POST['searchterm']) && !empty($_POST['searchterm'])){
//			//clean the string, just in case
//			$searchterm = strip_tags($_POST['searchterm']);
//			//get the results if any
//			$posts = $this->posts->search($searchterm);
//		}
//
//		//if request came from a JSON application
//		if($transport == 'json'){
//			//output the encoded string
//			echo $this->json->encode($posts);
//			//and exit, no reason to continue
//			exit;
//		}
//
//		//assign post array
//		$this->data['posts'] = $posts;
//		//display the view
//		$this->render('livesearch');
//	}
//





